<!DOCTYPE HTML>
 <?php session_start();?>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
		<title>学生界面</title>
		<link rel="stylesheet" type="text/css" href="style.css"/>
	</head>
	
	<body>	
		<?php
		  include'../public/header.php'; 
		?>

<!-- 写日志 -->	
		<section>
			<form action="push_Log.php" method="post">

				<h1>Write article</h1>
				
				<input class="title" id="logTitle" name="logTitle"  type="text" style=" height:30px"/>
				
				<textarea id="logContent" name="logContent" name="txt"/></textarea>

				 <select id="logUnit" name="logUnit">
                  <option value="1"> Module 1 </option>
                  <option value="2"> Module 2 </option>
                  <option value="3"> Module 3 </option>
                  <option value="4"> Module 4 </option>
                </select>

                <select id="visible" name="visible">
                  <option value="1">公开</option>
                  <option value="0">不公开</option>
                </select>
				
				<input id="post" type="submit" value="Submit"/>
				<input type="reset" value="Reset"/>

			</form>
		</section>
		
	<!-- 我的日志 -->	
		<aside>
			<h1>My article</h1>
			<ul>
				   <!--连接数据库-->
      			<?php
  				    $conn;
			        include '../public/conn.php';

				    // 检查是否已设置session
					$strName=$_SESSION['userName'];
				    $id=mysql_query("select sid from student where sna='$strName'", $conn);
				    $row=mysql_fetch_array($id);
				    $sID=$row['sid'];
				    $_SESSION['sid'] = $sID;

					//读取数据
					$res=mysql_query("select * from log where sid=$sID ");
					$rows=mysql_num_rows($res);
					$row = mysql_fetch_array($res);

                    //循环输出用户日志
					for($i=0; $i<$rows; $i++){

						$title = $row['log_title'];
						$log_date = $row['log_date'];
						$log_time = $row['log_time'];
				?>
				<li>
<!-- ? -->		 <a href="../log/log_read.php?id=<?php echo $row['log_id'] ?>">
				  <?php echo ($i+1).". ".$title."------".$log_date."-".$log_time; ?>
				  </a>
				</li>

				<li>
					<a href="stu_edit.php?id= <?php echo $row['log_id']?>">编辑</a>
				    |<a href="del.php?del= <?php echo $row['log_id']?>">删除</a>
				</li>
			    
				<?php 
					$row = mysql_fetch_array($res);
				}?>
			</ul>
		</aside>
		
		<div id="dec"><img id="decimg" src="1.jpg"/></div>
		
		<div id="stu">
			<img id="stuimg" src="sinfor.jpg"/>
			
			<?php 
		      if(isset($_SESSION['userName'])){
	            echo "<h3>Hello！".$_SESSION['userName']."同学</h3>";
		       }
		       else {
	             echo "<script>";
	             echo "alert('You are not logged, please login.');";
	             echo "location.href = '../reg_login/sign.html#r';";
	             echo "</script>";	
	           }
	        ?>
			<h5>Num of articles<span><?php echo $rows;?></span></h5>
		</div>		
	</body>
</html>